/**
 * @file xcd_x11.h
 * @brief X11 interface functions.
 * @author Guo-Rong Koh
 * @date 24 February 2008
 *
 * @par Copyright Notice
 * Copyright Guo-Rong Koh 2008.
 */

/*
 * This file is part of xceed.
 *
 * xceed is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License Version 2 as published by the Free
 * Software Foundation.
 *
 * xceed is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * xceed.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef XCD_X11_H
#define XCD_X11_H 1

#include <X11/Xlib.h>

/**
 * Display resolution type.
 *
 * Contains the width and height of a display in pixels.
 */
typedef struct
{
    /** Width of the display in pixels. */
    unsigned short width;

    /** Height of the display in pixels. */
    unsigned short height;

} xcd_resolution_t;

/**
 * Display head type.
 *
 * Contains the state information for a single connected head.
 */
typedef struct
{
    /** Resolution of the head. */
    xcd_resolution_t resolution;

} xcd_head_t;

/**
 * Initialise X11 for xceed.
 *
 * @return The root X display, NULL if the X11 initialisation failed.
 */
Display *xcd_x11_init(void);

/**
 * Uninitialise X11 for xceed.
 *
 * @param[in] display Root display.
 */
void xcd_x11_exit(Display *display);

/**
 * Gather a list of enabled heads.
 *
 * Returns an array of heads and their state information.
 *
 * @note Must be freed with xcd_x11_free_heads().
 *
 * @param[in]  display Display to query.
 * @param[out] count   Number of heads detected.
 *
 * @return An allocated array of heads. NULL if no heads found.
 */
xcd_head_t *xcd_x11_get_heads(Display *display, int *count);

/**
 * Free a list of heads.
 *
 * @param[in] heads List of heads to free.
 */
void xcd_x11_free_heads(xcd_head_t *heads);

#endif
